<template>
  <div class="markdown-preview">
    <div v-html="content">
      article content
    </div>
  </div>
</template>

<script>
export default {
  async asyncData({ app, params, env, error }) {
    const incurl = `${env.apiServer.baseUrl}/article/inc/${params.articlePath}`;
    app.$axios.put(incurl)
      .then((res) => {
        // if (res.data.code === 0){
        //   console.log('inc succeccfully!');
        // } else {
        //   console.log('inc fail!' + res.data.message);
        // }
      })
      .catch(function (e) {
        // console.log(e.message);
      });

    const url = `${env.rootURL}/${params.articlePath}.html`;
    return app.$axios.get(url,{responseType: 'text'})
      .then((res) => {
        return { content: res.data };
      })
      .catch(function (e) {
        error({ statusCode: 404, message: e.message })
      });
  }
}
</script>

<style scoped>
</style>
